﻿using Booking_System.ServiceReference1;
using BookingSystemModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Booking_System
{
    /// <summary>
    /// Interaction logic for UCGetPhone.xaml
    /// </summary>
    public partial class UCGetPhone : UserControl
    {
        IInternalBookingService clientPhone;

        public UCGetPhone()
        {
            InitializeComponent();
            clientPhone = new InternalBookingServiceClient();
        }
        
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Int32 phoneNumber = 0;
            Int32.TryParse(number.Text, out phoneNumber);
            
            Booking_System.ServiceReference1.Phone phone = clientPhone.GetPhone(phoneNumber);
            
            if (phone == null)
                return;
            txtOutput.AppendText(phone.Id + " : " + phone.IsPrimary + "\n");
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            clientPhone.CreatePhone(true, null, null, null, 554685);
        }

        private void number_TextChanged(object sender, TextChangedEventArgs e)
        {

        }

        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            /*txtOutput.Clear();
            foreach(PhoneService.Phone phone in clientPhone.GetAllPhones())
            {
                txtOutput.AppendText(phone.Id + " : " + phone.Number + " (" + phone.IsPrimary + ")");
            }*/
        }
    }
}
